/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * \file
 * \brief Type definitions for a Emergency Stop interface. 
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 *
 * $Id: EmergencyStopTypes.hpp,v 1.4 2009-11-09 08:55:33 morsko Exp $
 *
 */
#ifndef _MACI_EMERGENCYSTOPTYPES_HPP_
#define _MACI_EMERGENCYSTOPTYPES_HPP_
#include <inttypes.h>
#include "ownutils.h"
#include "owndebug.h"
#include "timestamp.hpp"

namespace MaCI {

  /** MaCI - EmergencyStop interface.
   *
   * This namespace contains all the methods and types related
   * to the EmergencyStop interface.
   *
   * \note This interface is still under heavy developement. Please
   * consider this interface to be on Alpha stage of testing before
   * this note is removed!
   */
  namespace EmergencyStop {
    
    /** Enumeration types for EmergencyStop data elements.
     */
    enum EEmergencyStopType { 
      KTypeUnknown               = -1, ///< Unkown type.
      KTypeTimestamp             = 1,  ///< Common::TTimestamp element.
      KTypeCommand               = 2,  ///< TCommand element.
      KTypeEmergencyStopStatus   = 3,  ///< TEmergencyStopStatus element.
      KTypeTimeoutTime           = 4,  ///< TTimeoutTime element.
    };

    /** Enumerations for EmergencyStop Command.
     */
    enum EEmergencyStopCommand { 
      KCommandUnknown = 0,                    ///< Unknown command
      KCommandClientAlive = 1,                ///< Command for client watchdog
      KCommandActivateEmergencyStop = 2,      ///< Command for activating emergency stop
      KCommandDeactivateEmergencyStop = 3,    ///< Command for deactivating emergency stop
      KCommandGetTimeoutTime = 4,             ///< Command for getting server side timeout time
      KCommandGetTimeoutReply = 5,            ///< Command for replying server side timeout time
      KCommandActivateClient = 7,
      KCommandDeactivateClient = 8,
      KCommandNoActiveClients = 9,
      KCommandStatusEvent = 10

    };

    /**
     * Enumeration for EmergencyStop status
     */
    enum EEmergencyStopStatus {
      KStatusEmergencyStopDeactivated = 0,     ///< Emergency stop is Deactivated
      KStatusEmergencyStopActivated = 1        ///< Emergency stop is Activated
    };

    /** EmergencyStop command.
     *
     * This structure contains command field to be used when sending
     * action requests to EmergencyStop enabled clients.
     *
     * \see EEmergencyStopCommand
     */
    struct TCommand 
    {
      TCommand(const unsigned int aCmd = 0) 
	: cmd(aCmd){}
      uint32_t cmd;             ///< Command
      
    };
  

    /** Emergency stop status
     *
     * Struct to define if the emergency stop is activated or deactivated.
     * 
     * \see EEmergencyStopStatus
     */
     struct TStatus{
      TStatus(const unsigned int aEmergencyStopStatus)
        : emergencyStopStatus(aEmergencyStopStatus){}
        
        uint32_t emergencyStopStatus;
     };

    /**
     * This is a timeout time (in ms) container
     */
    struct TTimeoutTime
    {
      TTimeoutTime(const uint32_t aTimeoutTime_ms =0.0)
        : timeoutTime_ms(aTimeoutTime_ms){}

      uint32_t timeoutTime_ms;


    };
  }
}

#endif
